﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Windows.Browser;

namespace SilverChart.Core.Util {
    public class BrowserUtil {
        public static void Alert(String message) {
            if (HtmlPage.BrowserInformation.UserAgent.Contains("Chrome")) {
                try {
                    //fix Google Chrome issue, when alert from silverlight, the browser will be crashed
                    //try invoke js helper, if it does not exist, use normal invocation approch
                    String Invokefunction = "alert(\"" + message + "\");";
                    HtmlPage.Window.Invoke("setTimeout", new Object[] { Invokefunction, 200 });
                    return;
                }
                catch {
                }
            }
            HtmlPage.Window.Alert(message);
        }
    }
}
